<template>
    <div>
        <Table>
            <tr>
                <th>头图</th>
                <th>商品名称</th>
                <th>商品价格</th>
                
                
            </tr>
            <tr>
                <th><img :src="'http://127.0.0.1:8000/static/upload/'+goodslist.img" width="240" height="240" class="rounded-corners img-fluid"></th>
                <th>{{goodslist.title}}</th>
                <th>{{goodslist.price}}</th>
            </tr>
            <th>商品评论</th><th>评论时间</th>
            <tr v-for="(item,index) in contentlist" :key="index">
                <td>{{username}}:</td>
                <td>{{item.content}}</td>
                <td>{{item.create_time|make_time}}</td>
            </tr>
            评论总数: {{this.contentlist.length}}
        </table>
        
 


    </div>
</template>

<script>
export default {
    data () {
        return {
            gid:'',
            goodslist:[],
            contentlist:[],
            username:''

            
        }
    },
    methods: {
        showcomment(){
            this.axios.get('http://localhost:8000/myroad/myroadshowcg/',{params:{gid:localStorage.getItem('gid')}})
            .then(result=>{
                console.log(result)
                this.goodslist=result.data.msg
                this.contentlist=result.data.msg2
                console.log(this.goodslist)
                console.log()
                
            })
        }
    },
    created() {
        this.showcomment()
        this.username=localStorage.getItem('username')
    },
   
    filters: {
        make_time(str){
            str=str.replace('T',' ')
            return str
        }
    }

}
</script>

<style>

</style>
